package com.p595263720.o_amap.map;

import android.content.Context;
import android.os.Bundle;

import com.amap.api.maps.AMapOptions;
import com.google.gson.Gson;
import com.p595263720.o_amap.LifecycleProvider;
import com.p595263720.o_amap.map.models.UnifiedAMapOptions;

import java.security.PublicKey;
import java.util.concurrent.atomic.AtomicInteger;

import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.StandardMessageCodec;
import io.flutter.plugin.platform.PlatformView;
import io.flutter.plugin.platform.PlatformViewFactory;

public class MapViewFactory extends PlatformViewFactory {
  
    
    private final BinaryMessenger binaryMessenger;
    private final LifecycleProvider lifecycleProvider;

    public MapViewFactory(BinaryMessenger messenger, LifecycleProvider lifecycleProvider) {
        super(StandardMessageCodec.INSTANCE);
        this.binaryMessenger = messenger;
        this.lifecycleProvider = lifecycleProvider;
    }

    @Override
    public PlatformView create(Context context, int viewId, Object args) {
        String options = (String) args;
        AMapOptions aMapOptions = new Gson().fromJson(options, UnifiedAMapOptions.class).toAMapOption();
        return new MyMapView(context, aMapOptions, viewId, binaryMessenger,lifecycleProvider);
    }
}
